let allPointsData = {}; //所有pointID的详细数据
let self = this;
let mySwiper;
let isPause = false; //是否寻路状态
let searchList = ''; //搜索的数据库
let realDistance = ""; //路线总长
let realTimeCountdown = ''; //耗时倒计时的计时器
let mytime = '';
let queryUrlData = '';
let allFloorData = '';
let floorListFlag = false; // 科室页数据是否已经请求到
let searchResultsOnMapBoxH //searchResultsOnMapBox的高
let isStart = false;
let isEnd = false; //已有路线，点击搜索栏是设置起点还是终点的判断
let fastSearchData = '' //快捷功能区数据
let departmentsInfo = '' //科室页的科室数据
let registeredDepartment = '' //挂号科室
let noMarkIsSetEnd = false; //是否卫生间   出入口类型
let facilityModify = false //是否卫生间  电梯等类型
let unableClick = {} //出入口  洗手间  等无法直接出发地图点击事件  传递他的pointid
let undergroundCompareFloorName; //地下楼层Name
let undergroundCompareFloorNameIndex; //地下楼层数字排序索引
let compareFloorName; //地上楼层的名字是什么
let compareFloorNameIndex; //地上楼层数字排序索引
let isLoadingEnd = false //加载loading完成判断
let noNametype = ['wheelchair wc', 'toilets', 'lifts', 'escalator', 'stair', 'nursery room', 'man toilets', 'woman toilets', 'handicapped washroom']
let keyArr = [] //搜索缓存数组
let rankPublic = ''
let commentPublic = ''
let popularSearchData = '' //热门搜索数据
var object = {
	no: "5", //一系列操作之后  展开楼层模块该显示楼层
	menuNo: '0',
	startP: '',
	endP: '',
	startFid: '',
	endFid: '',
	isFind: false, //是否在寻路状态下
	allFloorName: [], //所有楼层名字的对象
	xlId: {},
	allFoors: {},
	allNameFloor: {},
	zoomLevel: 20,
	isTrue: true, //静音   ios不兼容
	floorid: GetQueryString('floorid') ? GetQueryString('floorid') : MapConfig.initFloorID,
	mark: GetQueryString('mark'),
	departName: GetQueryString('departName'),
	floorName: GetQueryString('floorName'),
	mac: GetQueryString('mac'),
	ip: GetQueryString('ip'),
	mapDebug: window.location.search.search("debug") != -1,
	floorData: '',
	orderFloors: {},
	pointNames: {},
	order: null, //初始楼层order
	ispoint: true,
	isInitOrder: true,
	location: false,
	timer: '', //寻路定时器
	pathfinding: JSON.parse(GetQueryString('pathfinding')), //ids扫描跳转参数
	department: GetQueryString('department'),
	shopList: '',
	moFloorid: {
		start: '',
		end: '',
		startArea: '',
		endArea: ''
	},
	areaID: "",
	shopID: {
		id: 'L95',
		floorid: 'LG'
	},
	getServeData: function (data, fn) {
		$.ajax({
			type: "GET",
			url: 'https://map.ckiosk.cn/webAPI/ClientService.asmx/Command?callback',
			data: data,
			dataType: "JSONP",
			success: function (s) {
				fn(s);
			}
		});
	}
}
let yGetData = {
	getData: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {

			if (data.c == 200) {
				console.log('data :', data);
				fastSearchData = data.v.FunctionInfo
				if (data.v.DepartmentsInfo) {
					departmentsInfo = data.v.DepartmentsInfo
				}

				if (fastSearchData.length > 0 | departmentsInfo.length > 0) {
					createFloorList()
				}


			}
		})
	},
	getRegisteredData: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {
			console.log(data.v)
			if (data.c == 200 && data.v.length > 0) {
				registeredDepartment = data.v
			}
		})
	},
	updateHotPoint: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {})
	},
	getPopularSearch: function (pid, lan, command, parameter) {
		var datas = {
			"code": "{pid:'" + pid + "',lan:'" + lan + "',command:'" + command + "',parameter:" + JSON.stringify(parameter) + "}"
		}
		object.getServeData(datas, function (data) {
			if (data.c == 200 && data.v.length > 0) {
				popularSearchData = data.v
			}
		})
	},
}

let arr = [{
	'image': './images/Department_icon_quguahao.png',
	'searchName': '挂号处',
	'title': '去挂号'
}, {
	'image': './images/Department_icon_qujiaofei.png',
	'searchName': '收费处',
	'title': '去缴费'
}, {
	'image': './images/Department_icon_ququyao.png',
	'searchName': '去取药',
	'title': '去取药'
}, {
	'image': './images/Department_icon_qushuye.png',
	'searchName': '去输液',
	'title': '去输液'
}, {
	'image': './images/Department_icon_quchouxue.png',
	'searchName': '去抽血',
	'title': '去抽血'
}, {
	'image': './images/Department_icon_qubaogao.png',
	'searchName': '取报告',
	'title': '取报告'
}, {
	'image': './images/Department_icon_wc.png',
	'searchName': '洗手间',
	'title': '洗手间'
}, {
	'image': './images/Department_icon_churukou.png',
	'searchName': '出入口',
	'title': '出入口'
}]



// 二维码寻路
let qrCode = GetQueryString('qrCodePathFind'),
	urlStart = '',
	urlEnd = '',
	searchType = '',
	startFloor = '',
	endFloor = '';


$(document).ready(function () {
	$("title").html(MapConfig.title);
	setTimeout(() => {
		yGetData.getData(MapConfig.projectID, 'SC', 'gethospitalfunctioninfo', "{'KEY':'FB388CB1-3C10-4675-970C-C8C06EC7E55E'}")
		yGetData.getPopularSearch(MapConfig.projectID, 'SC', 'GetHotSearch', "{'KEY':'FB388CB1-3C10-4675-970C-C8C06EC7E55E'}")

	}, 0);
	if (object.pathfinding) {
		object.floorid = object.pathfinding.startFloorid
	}

	if (object.mapDebug) {
		MapConfig.debug = true;
	}
	init()
	searchList = GIM.DisplayModel.prototype.allArea;

	$('.compass').on('click', function () {
		self.map.setPolarAngle(MapConfig.polarAngle);
		self.map.setAzimuthalAngle(MapConfig.azimuthalAngle);
		$(this).css({
			'transform': 'rotate(90deg)'
		})
	});

});


window.alert = function (name) {
	var iframe = document.createElement("IFRAME");
	iframe.style.display = "none";
	iframe.setAttribute("src", 'data:text/plain,');
	document.documentElement.appendChild(iframe);
	// window.frames[0].window.alert(name);
	iframe.parentNode.removeChild(iframe);
};


//二维码寻路功能
if (qrCode) {
	var urlImg = JSON.parse(excludeSpecial(qrCode));
	urlStart = urlImg.sPI.toString();
	urlEnd = urlImg.ePI.toString();
	searchType = urlImg.type
	endFloor = urlImg.eFI
	startFloor = urlImg.sFI

}


// 关于点击 卫生间  电梯等的类型判断
function judgmentOfTheTypeOfPublicFacilities(type) {
	switch (type) {
		case 'wheelchair wc':
			x = "无障碍卫生间";
			break;
		case 'toilets':
			x = "卫生间";
			break;
		case 'lifts':
			x = "直梯";
			break;
		case 'escalator':
			x = "扶梯";
			break;
		case 'stair':
			x = "楼梯";
			break;
		case 'nursery room':
			x = "育婴室";
			break;
		case 'man toilets':
			x = "男士卫生间";
			break;
		case 'woman toilets':
			x = "女士卫生间";
			break;
		case 'handicapped washroom':
			x = "残疾人士卫生间";
			break;
	}
	return x
}


/**
 * @description 寻路事件
 *
 * @param {*} params
 */
function searchPath(params) {

	setTimeout(() => {
		self.map.startPID = urlStart;
	}, 100);


	setTimeout(() => {
		self.map.endPID = urlEnd;
	}, 800);




	setTimeout(() => {
		self.map.searchPath(function (msg) {
			if (msg) {

				let floorsData = [];
				endFloor = object.allNameFloor[endFloor]
				startFloor = object.allNameFloor[startFloor]

				realdistance = Math.ceil(msg.dis / 20);
				realTime = Math.ceil(realdistance / 1.1);
				object.startP = urlStart;
				object.endP = urlEnd;
				// 二维码寻路成功相关操作
				enterMap();
				// 起点终点提示

				if (urlStart.length > 15) {
					$('.opStartP').val(`${object.allFoors[startFloor]} 我的位置`)
				} else {
					$('.opStartP').val(`${object.allFoors[startFloor]} ${object.pointNames[urlStart]}`)
				}

				$('.opEndP').val(`${object.allFoors[endFloor]} ${object.pointNames[urlEnd]}`)
				$('.operation').show()
				$('.selectionBox,.selection,.pathChoiceLast').show();
				$('.selectionLoading,.pathChoice').hide();
				$('.pathChoiceLast').find('span').eq(0).html(formatSeconds(realTime) + '&nbsp&nbsp' + '约 ' + realdistance + ' 米')
				$('.pathChoiceLast').find('span').eq(1).html('到达目的地' + $('.opEndP').val())




				$(".swiper-wrapper1 li button").each(function (i) {
					var arr = {}
					arr.floorsId = $(this).attr("data")
					arr.floorsNo = $(this).attr("value")
					floorsData.push(arr)
				})
				var li = ''
				var floorIDsRe = msg.floorIDs.reverse()

				for (let i = 0; i < floorIDsRe.length; i++) {
					for (let j = 0; j < floorsData.length; j++) {
						if (floorIDsRe[i] == floorsData[j].floorsId) {
							li = li + '<li  class="floorToggleUl_List" id="floorToggleUl_List">' +
								'<i class="floorToggleMinUl_i"></i><button name="btn" data="' + floorsData[j].floorsId + '" value="' + floorsData[j].floorsNo + '" id ="' + floorsData[j].floorsNo + '" >' + floorsData[j].floorsNo + '</button>' +
								'</li>'
						}
					}
				}
				$(".floorToggle,.changeFBox").hide()
				$(".floorToggleMinUl").append(li)
				$(".floorToggleMinUl li").eq(-1).show().removeClass().addClass('floorToggleUl_List-active')
				$(".floorToggleMinUl li").eq(-1).attr('data', 'isMark')
				if (floorIDsRe.length == 1) {} else {
					for (let j = 0; j < floorIDsRe.length; j++) {
						$(".floorToggleMinUl li").eq(j + 1).find('i').show()
					}
					$(".floorToggleMinUl li").eq(-1).find('i').show().removeClass().addClass("floorToggleMinUl_iR")
				}
				$('.floorToggleMinUl').css('bottom', '3rem')

				$('.compass').css('top', '2.81rem')


				$(".startEndPointBar").find("span").eq(0).html(realdistance)
				$(".startEndPointBar").find("span").eq(1).html(formatSeconds(realTime))

				setTimeout(() => {
					self.map.showFloors([startFloor], true)
				}, 500)
			}

		}, searchType);
	}, 1000);

}


//初始化地图仰角 旋角  大小 位置
function mapResetPublic() {
	self.map.setPolarAngle(MapConfig.polarAngle);
	self.map.setAzimuthalAngle(MapConfig.azimuthalAngle);
	self.map.zoomLevel(MapConfig.zoomlevel)
	self.map.move2Point(MapConfig.movePosition);
}



//地图初始化参数配置
function init() {
	// 文本显示层级   数值越大  越容易显示
	GIM.SHOW_SPRITE_LENGTH = MapConfig.SHOW_SPRITE_LENGTH;
	/* 公共设施显示层级 */
	GIM.SHOW_Facility_LENGTH = MapConfig.SHOW_Facility_LENGTH;
	GIM.DEBUG_MODE = MapConfig.debug; //是否开启调试，true为开启，false为u开启，默认不开启
	var container = document.getElementById('mapContainer')
	container.style.cssText = "width:" + (container.clientWidth / 1) + "px;height:" + (container.clientHeight / 1) + "px;overflow: hidden;position: absolute;text-align:right";
	var params = {
		debug: MapConfig.debug,
		initCompleted: initCompelte,
		onSelected: onSelected,
		container: container,
		themeID: MapConfig.themeID,
		accessToken: MapConfig.accessToken,
		backgroundColor: MapConfig.backgroundColor,
		projectID: MapConfig.projectID,
		initFloorID: object.floorid,
		// cloudID: 'D2D2A1CC-BE08-4FA8-9559-DFE8C0C1F0A2',
		showLabelType: MapConfig.showLabelType,
		// crossBuild: MapConfig.crossBuild,
		groundLayer: MapConfig.groundLayer, //是否设置底图
		bgisSvg: MapConfig.bgisSvg, //地图是否是SVG格式  布尔值
	}
	pvuv(params.projectID);
	// 地图离屏幕的距离
	GIM.far = MapConfig.far;
	// 地图放大级别，数字越小放大级别越大
	GIM.near = MapConfig.near;

	self.map = new GIM.Map3D(params);

	self.map.maxFlatHeight = MapConfig.maxFlatHeight;
	self.map.facilityScale = MapConfig.facilityScale;
	self.map.maxCameraRadius = MapConfig.maxCameraRadius;
	self.map.pathElevation = MapConfig.pathElevation;
	self.map.simulateMoveSpeed = MapConfig.simulateMoveSpeed;
	self.map.setBackgroundColor(0xeffdf6);
	self.map.pathThickness = MapConfig.pathThickness;
	self.map.showCompass(MapConfig.compass);
	self.map.move2Point(MapConfig.movePosition);
	self.map.regCompassChange(function (angel) {
		$('.compass').css({
			'transform': 'rotate(' + (angel) + 'deg)'
		})
	})

}



//地图初始化后进行操作
function initCompelte($floorData) {

	// 所有pintID的信息
	allPointsData = GIM.Points;


	var floorDataRe = $floorData.reverse()

	// console.log('floorDataRe :', floorDataRe);

	allFloorData = $floorData
	// var a = GIM.Points
	object.floorData = floorDataRe;
	object.floorData = object.floorData.sort(function (a, b) {
		return b.Order - a.Order
	});
	object.floorData.forEach(function (t) {

		object.allFoors[t.FloorID] = t.Name
		object.orderFloors[t.Order -(object.floorData[object.floorData.length-1].Order - 1)] = t.FloorID
		object.allNameFloor[t.Name] = t.FloorID
		object.allFloorName.push(t.Name);
		t.Area.forEach(data => {
			object.pointNames[data.PI] = data.AN
		})

	})


	// 给快速商家搜索数据进行排序
	object.allFloorName.forEach(e => {
		if (e.indexOf("B") != -1) {
			undergroundCompareFloorName = "B"
			if(e.indexOf("B") == 0){
				undergroundCompareFloorNameIndex = 	1
			} else {
				undergroundCompareFloorNameIndex = 	0
			}
			
		}
		if (e.indexOf("L") != -1) {
			compareFloorName = "L"
			if(e.indexOf("L") == 0)	{
				compareFloorNameIndex = 1
			}else {
				compareFloorNameIndex = 0
			}	
		}
		if (e.indexOf("F") != -1) {
			compareFloorName = "F"
			if(e.indexOf("F") == 0)	{
				compareFloorNameIndex = 1
			}else {
				compareFloorNameIndex = 0
			}
		}
	})





	$(".exitConfirmation").css("opacity", "0")
	$(".exitConfirmation").css("top", "-.9rem")


	// 当科室页数据请求到时才渲染楼层数据
	if (floorListFlag) {
		bindFloor(object.floorData)
	}



	// 当从微信分享页面进入时
	if (GetQueryString('floorid') && GetQueryString('floorid') == queryUrlData.FloorID) {

		$('.floorToggle').html(queryUrlData.Name);
	}


	if (object.mark) { //分享

		setTimeout(() => {
			$(".message").hide()
		}, 0);
		if ($('.floorListInfo').css('display') == 'block') {
			$('.homePage').hide()
			$('.message').show()
			setTimeout(function () {
				$('.setPoint').slideDown()
				isStartBtnOrEndBtn(3)
				setPointBottom()
				self.map.zoomLevel(5);
				self.map.addMarkToPoint(object.mark, 'mark', true)

				$('.shareDataInput').val(object.pointNames[object.mark])
				$('.shareDataInput').html(object.pointNames[object.mark])
				$(".pointName").html(object.pointNames[object.mark])
				$('.pointFloor').html(`${object.pointNames[object.mark]} ${object.allFoors[object.floorid]}`)

				unableClick.pointID = object.mark;
				unableClick.floorID = object.floorid;
				unableClick.name = object.pointNames[object.mark];
			}, 500)
		}
	} else if (object.pathfinding) { //扫码
		self.map.startNode.pointID = object.pathfinding.startId;
		setTimeout(function () {
			$('#loadings').css({
					'display': 'block'
				}).children('.load_xun').css({
					display: 'block'
				})
				.siblings().css({
					display: 'none'
				})
			self.map.showFloors([object.pathfinding.endFloorid])
			self.map.setEndArea(object.pathfinding.endId, false);
			self.map.searchPath(function (msg) {
				if (msg == 'done') {
					selectionBoxBottm()
					self.map.zoomLevel(object.zoomLevel);
					$('#loadings').css('display', 'none')
				} else {
					$('#loadings').css('display', 'none')
					alert('寻路失败');
					return;
				}
			}, callback)
		}, 5000)
	} else if (object.department) { //挂号
		setTimeout(() => {
			yGetData.getRegisteredData(MapConfig.projectID, 'SC', 'gethospitaldepartmentstidsinfo', "{'KEY':'BAF3CB32-E8F2-40A6-AE1A-A5BFE2CB6E14'}")
		}, 0);
		if (self.map.pathDownloaded == true) {
			if (registeredDepartment.length > 0) {
				registrationMatching()
			} else {
				var timer = setInterval(function () {
					if (registeredDepartment.length > 0) {
						registrationMatching()
						clearInterval(timer)
					}
				}, 500)
			}
		} else {
			self.map.regPathDownloaded(function () {
				if (registeredDepartment.length > 0) {
					registrationMatching()
				} else {
					var timer = setInterval(function () {
						if (registeredDepartment.length > 0) {
							registrationMatching()
							clearInterval(timer)
						}
					}, 500)
				}
			})
		}

	} else {
		$(".floorToggle").html("1F")
		$('#loadings').css('display', 'none');
		$('.waiting').html('地图加载完成').delay(2500).fadeOut()
	}


	createWXConfig(postData);
	FloorDetection()

	if (qrCode) {
		if (self.map.pathDownloaded) {
			searchPath();
		} else {
			searchPath();
		}
	}

	self.map.regNavigationPause(function () {
		//暂停模拟导航的时候触发
		$(".endNavigationTime div").html("继续导航")
		$(".endNavigationTime div").css("color", "#18ad7c")
		$(".endNavigationTime").removeAttr("disabled");
		// clearInterval(endNavigationTime)
		isPause = true;
		isFloorToggleCounter = true;
		$(".floorToggleMinUl li button").removeAttr("disabled");
		if (realTimeCountdown != null) {
			clearTimeout(realTimeCountdown);
			realTimeCountdown = null;
		}
	})

	mapResetPublic()
}



// 挂号匹配函数
function registrationMatching() {
	for (var j = 0; j < registeredDepartment.length; j++) {
		if (registeredDepartment[j].ThirdPartyIDS.split("|").indexOf(object.department) != -1) {
			$(".homepage,.searchBox").hide()
			for (var i = 0; i < allFloorData.length; i++) {
				var allFloorDataA = allFloorData[i].Area
				for (var o = 0; o < allFloorDataA.length; o++) {
					if (registeredDepartment[j].PI == allFloorDataA[o].PI) {
						// console.log(allFloorDataA[o])
						$(".opEndP").val(allFloorDataA[o].Tag + ' ' + object.allFoors[registeredDepartment[j].FI] + ' ' + allFloorDataA[o].AN)
					}
				}
			}
			$(".floorToggle").html(object.allFoors[registeredDepartment[j].FI])
			$(".setPointTip,.operation").slideDown()
			setPointBottom()
			$('.compass').css({
				'top': '2.81rem'
			})
			$(".looking").show().html('正在查看 ' + object.allFoors[registeredDepartment[j].FI] + '')
			self.map.addMarkToPoint(registeredDepartment[j].PI, "end", true)
			object.endP = self.map.endPID = registeredDepartment[j].PI;
		} else {
			// $(".floorToggle").html("1F")
			// $(".looking").html('正在查看 ' + "1F" + '')
			// $('.waiting').show().html('未找到该科室，请确认后重试').delay(3500).fadeOut()
		}
	}
}

// 创建科室页科室列表
function createFloorList() {
	var li = ''
	var lis = ''
	var ul = ''
	for (var i = 0; i < departmentsInfo.length; i++) {
		var departmentsInfoData = departmentsInfo[i].data
		departmentsInfoData = departmentsInfoData.sort(compare('Order'))
		lis = '';
		for (var j = 0; j < departmentsInfoData.length; j++) {
			// console.log(departmentsInfoData[j])
			var departmentsInfoDataO = departmentsInfoData[j].data
			li = '';
			departmentsInfoDataO = departmentsInfoDataO.sort(compare('O'))
			for (var o = 0; o < departmentsInfoDataO.length; o++) {
				// console.log(departmentsInfoDataO)
				li = li + '<li onclick="toThisPoint(' + departmentsInfoDataO[o].PI + ',' + "\'" + departmentsInfoData[j].FI + "\'" + ',' + "\'" + departmentsInfoDataO[o].N + "\'" + ',' + 2 + ',' + "\'" + departmentsInfo[i].Name + "\'" + ')">' + '<span > ' + departmentsInfoDataO[o].N + ' </span>' + '</li > '
			}
			lis = lis + '<div class="buildingFloors">' + '<div class="buildingFloorsLeft">' + departmentsInfoData[j].Name + '</div>' + '<div class="buildingFloorsRight">' + li + '</div>' + '</div>'
		}
		ul = ul + '<div class="buildingBar">' + '<div class="buildingTitle" id="buildingTitle">' + '<span>' + departmentsInfo[i].Name + '</span>' + '<span>' + '</span>' + '</div>' + '<div class="buildingContent">' + lis + '</div>' + '</div>'
	}
	if (departmentsInfoDataO) {
		floorListFlag = true;
	}
	$(".floorListInfo").append(ul)
}


//创建楼层
function bindFloor($floorData) {
	var ul = $(".swiper-wrapper1"),
		liHtml = '';

	ul.find("li").remove();
	floorDataRe = $floorData.reverse()
	for (var i = floorDataRe.length - 1, len = floorDataRe.length; i >= 0; i--) {
		liHtml = liHtml + `<li name=${floorDataRe[i].FloorID} class="swiper-slide swiper-slide1"><button type="button" class="btn btn-default" data=${floorDataRe[i].FloorID} value =${floorDataRe[i].Name} >${floorDataRe[i].Name}</button></li>`;
		if (GetQueryString('floorid') && GetQueryString('floorid') == floorDataRe[i].FloorID && object.isInitOrder) {
			queryUrlData = floorDataRe[i];
			object.order = floorDataRe.length - floorDataRe[i].Order;
		}
		if (GetQueryString('pathfinding') && JSON.parse(GetQueryString('pathfinding')).startFloorid == floorDataRe[i].FloorID && object.isInitOrder) {
			object.order = floorDataRe.length - floorDataRe[i].order;
		}
	};
	// object.floorid = floorDataRe[floorDataRe.length - object.order - 1].FloorID

	ul.append(liHtml);
	mySwiper = myswiper(floorDataRe)
	mySwiper.init()
	var num = Math.ceil(arr.length / 8)
	var html = '';
	var htmls = '';
	var wrapper = $('.swiper-wrapper2')
	for (i = 0; i < num; i++) {
		html = html + '<div class="swiper-slide swiper-slide2 shortcut clearfix">' +
			'<ul class="pictures clearfix">' +
			'</ul>' +
			'</div>'
	}
	wrapper.append(html)
	var slide = $('.swiper-slide2');
	for (i = 0; i < slide.length; i++) {
		for (j = i * 8; j < arr.length; j++) {
			if (j == (i + 1) * 8) {
				break;
			}
			htmls = htmls + '<li onclick=searchTopic("' + (arr[j].searchName ? arr[j].searchName : '') + '")>' +
				'<img class="picture' + j + ' picture" src="' + arr[j].image + '">' +
				'</img>' +
				'<span>' + arr[j].title + '</span>' +
				'</li>'
		}
		$(slide[i]).find('ul').append(htmls)

		htmls = ''
	}
	$(".listLoading,.slideListLoading").hide()
	$(".floorListInfo,.slideList").show()
	setTimeout(() => {
		$('.buildingBar').fadeIn()
		$('.buildingBar').css('margin-top', '0')
		for (var i = 0; i < 9; i++) {
			if (i > 0) {
				$('.buildingBar').eq(i).find('div').eq(0).click()
			}
		}
	}, 100);
	$(".homePage .areaList .searchBar .enterMap").children().remove()
	$(".homePage .areaList .searchBar .enterMap").removeAttr("disabled")
	$(".homePage .areaList .searchBar .enterMap").html("地图")
	var mySwipers = new Swiper('.swiper-container2', {
		freeMode: false,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper  
		observeParents: true,
		pagination: '.swiper-pagination',
		pagination: '#swiper-pagination1',
		pagination: {
			el: '.swiper-pagination',
		},
	})

};


var afterFastSearchData = []


// 科室页快捷选单点击方法
function searchTopic(key) {
	afterFastSearchData = []
	noMarkIsSetEnd = false;
	facilityModify = false;
	for (var i = 0; i < fastSearchData.length; i++) {
		var arrD = fastSearchData[i].data
		for (var j = 0; j < arrD.length; j++) {
			if (key == fastSearchData[i].Name) {
				var arrS = {}
				arrS.PI = arrD[j].PI
				arrS.FloorID = arrD[j].FI
				arrS.BN = arrD[j].N
				arrS.T = arrD[j].T
				afterFastSearchData.push(arrS)
			} else if (key == '洗手间' || key == '出入口') {
				noMarkIsSetEnd = true
			} else if (key == '洗手间') {
				facilityModify = true
			}
		}
	}
	enterMap()
	toSearchResultsOnMap()
	self.map.zoomLevel(3)
}


function onSelected(data) {

	// console.log('data :', data);
	// console.log(object.allFoors[data.floorID])
	isLoadingEnd = true
	// $('#sousuo').removeClass().addClass('main_back')


	if (data.code == "section" || "entrance" || "toilets" || "stair" || "lifts" || "man toilets" || "woman toilets" || "cashier" || "handicapped washroom") {
		map.addMarkToPoint(data.nodeId, 'mark', true);
	}




	$('.floorToggle').html("" + object.allFoors[data.floorID] + "")

	self.map.zoomLevel(3)

	$('.inputName,.shares').css('display', 'none');
	$('.looking').hide().show().html('正在查看 ' + object.allFoors[data.floorID] + '');
	$('.gSearch').css('display', 'block');
	$('.mo_daohang,.mo_tishi').slideUp('slow');
	if (noNametype.indexOf(data.code) != -1) {
		$('.pointName').html(judgmentOfTheTypeOfPublicFacilities(data.code));
	} else {
		$('.pointName').html(data.shopName ? data.shopName : data.name);
	}
	$('.searchBox input').val($('.pointName').html())
	if (data.tag) {
		$('.pointFloor').html(data.tag + ' ' + object.allFoors[data.floorID]);
	} else {
		$('.pointFloor').html(object.allFoors[data.floorID]);
	}
	object.mark = data.nodeId
	object.floorid = data.floorID
	object.departName = $('.pointName').html()
	object.floorName = $('.pointFloor').html()
	if ($('.operation').css("display") == 'block') {
		$('.setPointTip').slideUp()
		$(".setPoint").slideDown()
		$(".setPoint .right").empty()
		if ($(".opEndP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
		} else if ($(".opStartP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
		}
		setPointBottom()
	} else if ($('.setPointTip').css("display") == 'block' && $('#endPoint').val() != '') {
		$('.setPointTip').slideUp()
		$(".setPoint").slideDown()
		$(".setPoint .right").empty()
		if ($(".opEndP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
		} else if ((".opStartP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
		}
		setPointBottom()
	} else if ($('.setPointTip').css("display") == 'block' && $('.setPoint').css("display") == 'block') {
		$('.setPointTip').slideUp()
		$(".setPoint").slideDown()
		$(".setPoint .right").empty()
		if ($(".opEndP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>选择终点</div>")
		} else if ($(".opStartP").val() == '') {
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStart()'>设为起点</div>")
		}
		setPointBottom()
	} else if ($(".searchResultsOnMapBox").css("display") == "block") {
		setPointBottom()
		$(".searchResultsOnMapBox").hide()
		$('.setPoint').slideDown()
	} else {
		setPointBottom()
		$(".setPoint .right").empty()
		$(".setPoint .right").append("<span class='setPointBtn'  onclick='setStartOrEnd()'></span>")
		$(".setPoint").slideDown()
	}
	if ($(".selectionBox").css('display') == 'block') {
		setPointBottom()
	}
	setStart = function () {
		self.map.cleanSelectUnit3D()
		object.xlId.startId = data.nodeId;
		object.moFloorid.start = data.floorID
		object.moFloorid.startArea = data.shopName ? data.shopName : data.name;
		object.startFid = data.floorID
		object.startP = self.map.startPID = data.nodeId;
		// console.log(object.startP)
		if (noNametype.indexOf(data.code) != -1) {
			if (data.tag) {
				$('#startPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			} else {
				$('#startPoint').val(object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			}
		} else {
			if (data.tag) {
				$('#startPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			} else {
				$('#startPoint').val(object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			}
		}
		$(".setPoint,.searchBox").slideUp()
		$(".operation").slideDown()
		setPointTipBottom()
		$(".compass").css("top", "2.81rem")
		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
	setEnd = function () {
		self.map.cleanSelectUnit3D()
		object.xlId.endId = data.nodeId;
		object.moFloorid.end = data.floorID
		object.moFloorid.endArea = data.shopName ? data.shopName : data.name
		object.endFid = data.floorID
		object.endP = self.map.endPID = data.nodeId;
		if (noNametype.indexOf(data.code) != -1) {
			if (data.tag) {
				$('#endPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			} else {
				$('#endPoint').val(object.allFoors[data.floorID] + ' ' + judgmentOfTheTypeOfPublicFacilities(data.code));
			}
		} else {
			if (data.tag) {
				$('#endPoint').val(data.tag + ' ' + object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			} else {
				$('#endPoint').val(object.allFoors[data.floorID] + ' ' + (data.shopName ? data.shopName : data.name));
			}
		}
		$(".setPoint,.searchBox").slideUp()
		// $(".searchBox").hide()
		$(".setPointTip,.operation").slideDown()
		setPointTipBottom()
		$(".compass").css("top", "2.81rem")
		setTimeout(() => {
			// $(".opStartP").focus()
		}, 0);
		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
	FloorDetection();
};






//起始点和终点交换
function twoPointExchange() {
	var middleID = ''
	var middleVal = ''
	if ($('.opStartP').val() != '') {
		middleVal = $('.opStartP').val();
	}
	self.map.clearPath(true)
	object.xlId.startId = object.startP
	object.xlId.endId = object.endP
	$('.floorToggleMinUl').children().remove()
	middleID = object.xlId.startId * 1;
	object.xlId.startId = object.xlId.endId * 1;
	object.xlId.endId = middleID;
	$('.opStartP').val($('.opEndP').val());
	$('.opEndP').val(middleVal);
	object.startP = self.map.startPID = object.xlId.startId;
	object.endP = self.map.endPID = object.xlId.endId;
	if ($('.setPointTip').css("display") == 'block' && $('.operation').css("display") == 'block') {
		if ($('.opStartP').val() == '') {
			$(".setPointTips").html("起点")
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if ($('.opEndP').val() == '') {
			$(".setPointTips").html("终点")
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
	} else {
		if ($('.opStartP').val() == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if ($('.opEndP').val() == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
	}
	reverseInside()
	pathGo('liftsFirst')
}

//返回 
function goBack() {


	if (qrCode) {
		self.map.showFloors([startFloor], true);
	}

	$('#startPoint').val("")
	$('#endPoint').val("")
	if (dataFloorId) {
		self.map.showFloors([dataFloorId])
		$(".floorToggle").html(object.allFoors[dataFloorId])
	} else {
		if (nowFloorId) {
			self.map.showFloors([nowFloorId])
			$(".floorToggle").html(object.allFoors[nowFloorId])
		}
	}
	goBackInside()
	dataFloorId = ''
	object.mark = ''
	unableClick = {}
	object.isTrue = true;
	object.isFind = false
	self.map.areaClickEmbed = true;
	$(".changeFBox,.searchResultsOnMapBox,.shares").slideUp()
	$(".searchBox,.scale").show()
	$('#endPoint,#startPoint').val(' ');
	$(".opStartP,.opEndP").val('')
	$('.gSearch,.inputName, .operation, .setPoint1, .setPoint, #loadings,.setPointTip,.selectionBox').hide();
	normalBottom()
	$('.compass').css({
		'top': '1.1rem'
	})
	$('.searchInput input').val("")
	self.map.clearPath(true);
	self.map.cleanSelectUnit3D()
	// 清除mark标记
	self.map.mark.visible = false;
	mapPositonReset()
	FloorDetection()


}


// 分享点击方法
function share(number) {
	if (number == 1) {
		$('.setPoint').slideUp('slow');
		$('.shares').slideDown('slow')
	} else {
		$('.setPoint').slideDown('slow');
		$('.shares').slideUp('slow')
	}
}

// 放大地图
function biger() {
	self.map.cameraRadius = self.map.cameraRadius - 1000
}

// 缩小地图
function smaller() {
	self.map.cameraRadius = self.map.cameraRadius + 1000
}




// 模拟导航语音方法
function audioAutoPlay(id, otext, ospd) {
	if (object.isTrue) {
		$.get("https://service.chaunve.com/TTSWebService.asmx/BaiduTTS?", {
				"text": otext,
				"spd": ospd
			},
			function (data) {
				// console.log(data)
				$(".mo_yuyin").attr("src", data);
				// $(".mo_yuyin").attr("autoplay", "true")
			})
		var audio = document.getElementById(id)
		play = function () {
			audio.play();
			document.removeEventListener("touchstart", play, false);
		};
		audio.play();
		document.addEventListener("WeixinJSBridgeReady", function () {
			play();
		}, false);
		document.addEventListener('YixinJSBridgeReady', function () {
			play();
		}, false);
		$(".mo_yuyin").attr("src", "");
	}
}


// 终点类型判断数组
var endPointType = ["carport", "Presentation action", "Supermarket action", "Register action", "	exsanguinate action", "	infusion action", "Pharmacy action", "entrance", "atm action", "toilets", "section", "wheelchair wc", 'Lifts', 'Escalator', 'stair', 'nursery room']

// 模拟导航倒计时方法
function NavigationCountdown() {
	realTime -= 1.8
	if (realTime > 0) {
		$(".endNavigationTime div").html("预计" + formatSeconds(realTime) + "后达到")
	} else {
		$(".endNavigationTime div").html("您已到达目的地附近")
	}

	realTimeCountdown = setTimeout("NavigationCountdown()", 1000)
}


var saveFloorIDsArr = []
// 模拟导航方法
function simulateNavigate() {

	audioAutoPlay("mo_yuyin", "开始导航", "5")
	$('.pathInfo').fadeOut(500);
	setTimeout(() => {
		if (object.startP == object.endP) {
			$(".searchPathFailMsg").html("起始点相同,请重新设置")
			$(".searchPathFailBox").fadeIn()
			return
		} else {
			$(".floorToggle,.floorToggleMinUl,.scale").css("bottom", "1.4rem")
			$(".inNavigationBotBar").css("opacity", "1")
			$('.inNavigationTopBarBox,.inNavigationBotBarBox').slideDown();
			$('.looking,.operation,.selectionBox,.setPoint,.setPointTip').hide()
			$('.compass').css('top', '2.28rem');
			var i = 1;
			object.timer = setInterval(function () {
				i = i + 1;
			}, 1000)
			setTimeout(() => {
				$(".floorToggleMinUl li").eq(-1).removeClass().addClass('floorToggleUl_List-active');
				$(".floorToggleMinUl li").eq(-1).siblings().removeClass().addClass('floorToggleUl_List')
				$(".floorToggleMinUl li").eq(-1).find("i").removeClass().addClass('floorToggleMinUl_iR');
				$(".floorToggleMinUl li").eq(-1).siblings().find("i").removeClass().addClass('floorToggleMinUl_i')
			}, 0);
			NavigationCountdown()
			self.map.zoomLevel(3);
			$(".floorToggleMinUl li button").attr("disabled", "true")
			$('.turnInfoText').html('请沿当前路线行走');
			$('.destinationInfo span').html('' + $('#endPoint').val() + '')
			var rightArr = []
			var leftArr = []
			var LeftFrontArr = []
			var RightFrontArr = []
			var endArr = []
			self.map.simulate()
			self.map.regNavigationWalk(function (walkDetail) {
				// console.log(walkDetail)
				nowFloorId = walkDetail.floorID
				var arrO = {}
				arrO.floorID = nowFloorId
				arrO.floorNo = object.allFoors[nowFloorId]
				saveFloorIDsArr.push(arrO)
				// console.log(nowFloorId)
				$(".mo_distance").html(walkDetail)
				if (walkDetail.z == 0) {
					$('.turnInfoImg').css({
						'background': 'url("./images/icon_fx_zhixing.png")',
						'backgroundSize': 'contain'
					})
					if (walkDetail.turn == 'Right') {
						$('.turnInfoText').html(+Math.ceil(walkDetail.dis / 20) + '米后右转')
						/* 取最大值 */
						rightArr.push(walkDetail.dis)
						if (walkDetail.dis == Math.max.apply(null, rightArr)) {
							var rightDis = Math.ceil(Math.max.apply(null, rightArr) / 20)
							if (rightDis > 15) {
								setTimeout(() => {
									audioAutoPlay("mo_yuyin", "" + rightDis - 4 + "米后右转", "5")
								}, 1500);
							}
						}
						if (Math.ceil(walkDetail.dis / 20) > 0) {
							$('.turnInfoImg').css({
								'background': 'url("./images/icon_fx_youzhuan.png") center center no-repeat',
								'backgroundSize': 'contain'
							})
						}
						if (walkDetail.dis > 70 && walkDetail.dis < 80) {
							audioAutoPlay("mo_yuyin", "前方右转", "5")
						} else if (walkDetail.dis == 0) {
							$('.turnInfoText').html('右转')
						}
					} else if (walkDetail.turn == 'Left') {
						$('.turnInfoText').html(+Math.ceil(walkDetail.dis / 20) + '米后左转')
						leftArr.push(walkDetail.dis)
						// console.log(Math.max.apply(null, leftArr))
						if (walkDetail.dis == Math.max.apply(null, leftArr)) {
							var leftDis = Math.ceil(Math.max.apply(null, leftArr) / 20)
							if (leftDis > 15) {
								setTimeout(() => {
									audioAutoPlay("mo_yuyin", "" + leftDis - 4 + "米后左转", "5")
								}, 1500);
							}
						}
						if (Math.ceil(walkDetail.dis / 20) > 0) {
							$('.turnInfoImg').css({
								'background': 'url("./images/icon_fx_zuozhuan.png") center center no-repeat',
								'backgroundSize': 'contain'
							})
						}
						if (walkDetail.dis > 70 && walkDetail.dis < 80) {
							audioAutoPlay("mo_yuyin", "前方左转", "5")
						} else if (walkDetail.dis == 0) {
							$('.turnInfoText').html('左转')
						}
					} else if (walkDetail.turn == 'LeftFront') {
						$('.turnInfoText').html(+Math.ceil(walkDetail.dis / 20) + '米后左转')
						// 取最大值
						LeftFrontArr.push(walkDetail.dis)
						// console.log(Math.max.apply(null, rightArr))
						if (walkDetail.dis == Math.max.apply(null, LeftFrontArr)) {
							var LeftFrontDis = Math.ceil(Math.max.apply(null, LeftFrontArr) / 20)
							if (LeftFrontDis > 15) {
								setTimeout(() => {
									audioAutoPlay("mo_yuyin", "" + LeftFrontDis - 4 + "米后左转", "5")
								}, 1500);
							}
						}
						if (Math.ceil(walkDetail.dis / 20) > 0) {
							$('.turnInfoImg').css({
								'background': 'url("./images/icon_fx_zuozhuan.png") center center no-repeat',
								'backgroundSize': 'contain'
							})

						}
						if (walkDetail.dis > 70 && walkDetail.dis < 80) {
							$('.turnInfoText').html('前方左转')
							audioAutoPlay("mo_yuyin", "左转", "5")
						}
					} else if (walkDetail.turn == 'RightFront') {
						$('.turnInfoText').html(+Math.ceil(walkDetail.dis / 20) + '米后右转')
						// 取最大值
						RightFrontArr.push(walkDetail.dis)
						if (walkDetail.dis == Math.max.apply(null, RightFrontArr)) {
							var RightFrontDis = Math.ceil(Math.max.apply(null, RightFrontArr) / 20)
							if (RightFrontDis > 15) {
								setTimeout(() => {
									audioAutoPlay("mo_yuyin", "" + RightFrontDis - 4 + "米后右转", "5")
								}, 1500);
							}
						}
						if (Math.ceil(walkDetail.dis / 20) > 0) {
							$('.turnInfoImg').css({
								'background': 'url("./images/icon_fx_youzhuan.png") center center no-repeat',
								'backgroundSize': 'contain'
							})

						}
						if (walkDetail.dis > 70 && walkDetail.dis < 80) {
							$('.turnInfoText').html('右转')
							audioAutoPlay("mo_yuyin", "前方右转", "5")
						}
					} else if ((walkDetail.turn == 'Lifts' && walkDetail.dis == 0) || (walkDetail.turn == 'Escalator' && walkDetail.dis == 0) || (walkDetail.turn == 'stair' && walkDetail.dis == 0)) {
						setTimeout(() => {
							if (walkDetail.nextFloorID) {
								if (walkDetail.turn == 'Lifts') {
									// console.log(object.allFoors[walkDetail.nextFloorID].substring(0,1))
									audioAutoPlay("mo_yuyin", "请乘直梯至" + object.allFoors[walkDetail.nextFloorID].substring(0, 1) + "楼", "5")
								} else if (walkDetail.turn == 'Escalator') {
									audioAutoPlay("mo_yuyin", "请乘扶梯至" + object.allFoors[walkDetail.nextFloorID].substring(0, 1) + "楼", "5")
								} else if (walkDetail.turn == 'Stair') {
									audioAutoPlay("mo_yuyin", "请走楼梯至" + object.allFoors[walkDetail.nextFloorID].substring(0, 1) + "楼", "5")
								}
							} else if (walkDetail.floorID) {
								if (walkDetail.turn == 'Lifts') {
									// console.log(object.allFoors[walkDetail.nextFloorID].substring(0,1))
									audioAutoPlay("mo_yuyin", "请乘直梯至" + object.allFoors[walkDetail.floorID].substring(0, 1) + "楼", "5")
								} else if (walkDetail.turn == 'Escalator') {
									audioAutoPlay("mo_yuyin", "请乘扶ss至" + object.allFoors[walkDetail.floorID].substring(0, 1) + "楼", "5")
								} else if (walkDetail.turn == 'stair') {
									audioAutoPlay("mo_yuyin", "请走楼梯至" + object.allFoors[walkDetail.floorID].substring(0, 1) + "楼", "5")
								}
							}
						}, 0);
						setTimeout(() => {
							$(".floorToggleUl_List-active").prev().removeClass().addClass("floorToggleUl_List-active").siblings().removeClass().addClass("floorToggleUl_List")
							$(".floorToggleUl_List-active").find("i").removeClass().addClass("floorToggleMinUl_iR").parent().siblings().find("i").removeClass().addClass("floorToggleMinUl_i")
							$(".floorToggleUl_List-active").attr('data', 'isMark')
							$(".floorToggleUl_List-active").siblings().attr('data', ' ')
						}, 500);
					} else {
						$('.turnInfoText').html(+Math.ceil(walkDetail.dis / 20) + '米后到达终点')
						endArr.push(walkDetail.dis)
						if (walkDetail.dis == Math.max.apply(null, endArr)) {
							var endDis = Math.ceil(Math.max.apply(null, endArr) / 20)
							if (endDis > 15) {
								setTimeout(() => {
									audioAutoPlay("mo_yuyin", "" + endDis - 6 + "米后到达目的地", "5")
								}, 1500);
							}
						}
						if (walkDetail.dis == 0 && walkDetail.turn == "end") {
							audioAutoPlay("mo_yuyin", "已到达目的地附近，感谢使用创互地图", "5")
							$('.turnInfoText').html('已到达')
							clearInterval(object.timer)
							clearInterval(realTimeCountdown)
							$('#startPointOfEnd').val('' + $('.opStartP').val() + '')
							$('#endPointOfEnd').val('' + $('.opEndP').val() + '')
							$(".endOfNavigationBox").fadeIn()
							$('.scale,.floorToggle,.floorToggleMinUl,.inNavigationBotBarBox').hide()
						}
					}
				} else {}
			});
		}
	}, 1000);

}



// 继续模拟导航方法
function continueToNavigate() {
	if (isPause == true) {
		continueToNavigateInside()
		self.map.toggleSimulate(true)
		$(".looking").hide()
		self.map.showLocation()
		self.map.zoomLevel(5)
		isPause = false;
		NavigationCountdown()
	}
	isFloorToggleCounter = false;
	floorCounter = 0;
	$(".floorToggleMinUl li button").attr("disabled", "true")
	$(".endNavigationTime").attr("disabled", "true")
}


// 寻路报错弹框方法
function searchPathFailClose() {
	$(".searchPathFailBox").hide()
	goBack();
}


// 模拟导航声音关闭方法   不兼容iso
function volumeOnOff(span) {
	var autoplay_audio = $("#mo_yuyin")[0];
	if (object.isTrue) {
		$(".endNavigationVoice span").css({
			'background': "url('./images/icon_jingyin.png')",
			'backgroundSize': 'contain'
		});
		autoplay_audio.volume = 0
		object.isTrue = !object.isTrue;
	} else {
		// $('#speed').html($('.turnInfoText').text())
		$(".endNavigationVoice span").css({
			'background': "url('./images/icon_shengyin.png')",
			'backgroundSize': 'contain'
		});
		autoplay_audio.volume = 1;
		object.isTrue = !object.isTrue;
	}
}


// 模拟导航声音关闭方法
function muteFun(span) {
	if (object.isTrue) {
		$(".endNavigationVoice span").css({
			'background': "url('./images/icon_jingyin.png')",
			'backgroundSize': 'contain'
		});
		object.isTrue = !object.isTrue;
	} else {
		$(".endNavigationVoice span").css({
			'background': "url('./images/icon_shengyin.png')",
			'backgroundSize': 'contain'
		});
		object.isTrue = !object.isTrue;
	}
}


//分享
$(".sharedbtn").click(function () {
	$(".sharemask").show();
})
$(".sharemask").click(function () {
	$(".sharemask").hide();
})

// 截取url参数
function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);

	if (r != null) return decodeURI(r[2]);
	return null;
}


function replaceArg(url, arg, arg_val) {
	var pattern = arg + '=([^&]*)';
	var replaceText = arg + '=' + arg_val;
	if (url.match(pattern)) {
		var tmp = '/(' + arg + '=)([^&]*)/gi';
		tmp = url.replace(eval(tmp), replaceText);
		return tmp;
	} else {
		if (url.match('[\?]')) {
			return url + '&' + replaceText;
		} else {
			return url + '?' + replaceText;
		}
	}
	return url + '\n' + arg + '\n' + arg_val;
}

function replaceUrl($url) {
	var url = $url
	if (url.indexOf('?') == -1) {
		if (object.floorid) {
			url = url + '?floorid=' + object.floorid;
		} else {
			return
		}
		if (object.mark) {
			url = url + '&mark=' + object.mark
		} else {
			return
		}
		// if (object.departName) {
		// 	url = url + '&departName=' + "\'" + object.departName + "\'";
		// } else {
		// 	return
		// }
		// if (object.floorName) {
		// 	url = url + '&floorName=' + +"\'" + object.floorName + "\'";
		// } else {
		// 	return
		// }
	} else {
		if (object.floorid) {
			url = replaceArg(url, 'floorid', object.floorid);
		} else {
			return
		}
		if (object.mark) {
			url = replaceArg(url, 'mark', object.mark);
		} else {
			return
		}
		// if (object.departName) {
		// 	url = replaceArg(url, 'departName', +"\'" + object.departName + "\'");
		// } else {
		// 	return
		// }
		// if (object.floorName) {
		// 	url = replaceArg(url, 'floorName', +"\'" + object.floorName + "\'");
		// } else {
		// 	return
		// }
	}
	return url
}


// 楼层模块滑动切换方法
function myswiper($floorData) {

	return new Swiper('.swiper-container1', {
		on: {
			click: function () {
				object.floorid = object.orderFloors[$floorData.length - mySwiper.activeIndex]

				$('.looking').hide().show().html('正在查看 ' + object.allFoors[object.floorid] + '');
				$('.floorToggle').html("" + object.allFoors[object.floorid] + "")
				self.map.showFloors([object.floorid])
				$(".changeFBox,.searchResultsOnMapBox").slideUp()
				self.map.regShowLoading(function (ccc) {
					if (ccc == true) {
						$('.loadings').show()
					}
					if (ccc == false) {
						$('.loadings').hide()
						mapPositonReset()
					}
				})
				mapPositonReset()
				$(".searchInput input").val('')
				if ($('.operation').css("display") == 'block') {
					$('.floorToggleMinUl,.scale,.changeFBox').css('bottom', '2.5rem');
					$(".floorToggle").css('bottom', '2.45rem')
					if (object.startP != '') {
						$(".setPoint").show()
					} else {
						$(".setPoint").hide()
					}
					$('.inputName, .setPoint1,.shares').css('display', 'none');
				} else {
					normalBottom()
					if (object.startP != '' || object.endP != '') {
						$(".setPoint").show()
					} else {
						$(".setPoint").hide()
					}
					$('.inputName, .setPoint1,.shares,.operation,.setPointTip').css('display', 'none');
				}
				$(".floorToggle").fadeIn()
			},
			touchStart: function () {
				Swiper.slideToclickedSlide = false;
			},
			init: function () {
				console.log("myswiper was init")
			}
		},
		init: true,
		direction: 'vertical',
		slidesPerView: 'auto',
		initialSlide: object.no,
		slideToClickedSlide: true,
		centeredSlides: true,
		freeMode: true,
		preventClicks: false,
		preventLinksPropagation: false, //阻止滑动点击
		preventclicksPropagation: false,
		touchRatio: 1.5, //触摸变慢
		// shortSwipes: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //将observe应用于Swiper的父元素。当Swiper的父元素变化时，例如window.resize，Swiper更新
		// hashNavigation: true,
	});
}


// 快捷选单滑动方法
function quickMenuSwiper() {
	return new Swiper('.swiper-container2', {
		pagination: {
			el: '.swiper-pagination',
		},
		initialSlide: object.menuNo,
		centeredSlides: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
	})
}


// 进入搜索页面方法
function goSearch() {
	var li = ''
	var lis = ''
	$('.searchResults').css('border', '')
	$(".main").children().children().find('div').eq(2).hide()
	$(".main").children().children().find('div').eq(3).fadeIn()
	$('.searchResults').children().remove()
	$(".homePage").fadeOut()
	$('.buildingBar').css('margin-top', '4rem')
	$('.main').fadeIn();
	$('.clearHistoryLabel,.searchBox').show()
	// $(".main .gSearch input").focus()
	$(".searchInput input").val('')
	$(".qingKong").css("opacity", "0")
	$(".mainInput").focus()
	keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
	keyArr = uniq(keyArr, "name")
	$('.popularSearch').children().remove()
	$('.searchResults').children().remove()
	if (keyArr.length > 0) {
		for (var o = 0; o < keyArr.length; o++) {
			li = li + '<li>' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo"  onclick="historySearch(' + "\'" + keyArr[o].name + "\'" + ', ' + "\'" + keyArr[o].floor + "\'" + ')">' + '<span>' + keyArr[o].name + '</span>' + '<div>' + '</div>' + '<span class="searchResultsInfoFloor">' + keyArr[o].floor + '</span>' + '</div>' + '</li>'
		}
		$('.searchResults').append(li)
	}
	if (popularSearchData.length > 0) {
		var lis = ''
		for (var o = 0; o < popularSearchData.length; o++) {
			if (o < 2) {
				lis = lis + '<li onclick="toThisPoint(' + popularSearchData[o].PI + ',' + "\'" + popularSearchData[o].FI + "\'" + ',' + "\'" + popularSearchData[o].Name + "\'" + ',' + 2 + ',' + "\'" + popularSearchData[o].Tag + "\'" + ')">' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo">' + '<span>' + popularSearchData[o].Name + '</span>' + '<div>' + '</div>' + '<span>' + popularSearchData[o].Tag + '   ' + object.allFoors[popularSearchData[o].FI] + '</span>' + '</div>' + '</li>'
			}
		}
		$('.popularSearch').append(lis)
	}
	if ($('.searchResults').children().length == '') {
		$('.clearHistoryLabel').hide()
	}
}


// 清空搜索缓存方法
function clearHistoryFun() {
	var arrClear = []
	localStorage.setItem(MapConfig.keyStorage, JSON.stringify(arrClear))
	$('.clearHistoryLabel').hide()
	$('.searchResults').css('border', '')
	$('.searchResults').children().remove()
}


//历史记录搜索方法
function historySearch(name, floor) {
	if (floor == '点击查看更多结果') {
		matchData(name)
		toSearchResultsOnMap(name)
	} else {
		matchData(name)
		$('.searchResults').find('li').eq(0).click()
	}
}


var toClose = true
//科室页楼层展示 伸缩
$(".floorListInfo").on("click", '#buildingTitle', function () {
	if ($(this).siblings().css('display') == 'block') {
		// zhankai
		$(this).siblings().slideUp()
		// toClose = !toClose
		setTimeout(() => {
			$(this).siblings().children().eq(0).css("border-top", "1px solid #e5e5e5")
			$(this).parent().css("border-radius", '.1rem')
		}, 400);
		$(this).removeClass().addClass("buildingTitleC")
	} else {
		$(this).siblings().slideDown()
		// toClose = !toClose
		$(this).removeClass().addClass("buildingTitle")
		$(this).siblings().children().eq(0).css("border-top", "0")
		$(this).parent().css("border-radius", '.1rem .1rem 0 0')
	}
})


//进入地图页
function enterMap() {
	$(".homePage").fadeOut()
	$(".main").fadeOut()
	$('.buildingBar').css('margin-top', '4rem')
	if ($(".searchResultsOnMapBox").css('display') == 'block') {
		$(".searchResultsOnMapBox").show()
	}
}


//进入科室页
function enterHomePage(type) {
	setTimeout(() => {
		quickMenuSwiper().progress;
		quickMenuSwiper().pagination.update()
	}, 0);
	isStart = false;
	isEnd = false
	$(".main").hide()
	$(".homePage,.clearHistoryLabel").fadeIn()
	$('.buildingBar').css('margin-top', '0')
	$(".hpInput").val("")
	if ($(".searchResultsOnMapBox").css('display') == 'block') {
		$(".searchResultsOnMapBox").show()
	}
	if (type == 'isStart') {
		isStart = true
		isEnd = false
	} else if (type == 'isEnd') {
		isEnd = true
		isStart = false
	}
}


// 判断input的value判断清空按钮显隐
function checkInput(e) {
	var oVal = $(e).val();
	if (oVal == "") {
		$(".qingKong").css("opacity", "0")
		$('.clearHistoryLabel').hide()
		$('.searchResults').css('border', '')
		$(".main").children().children().find('div').eq(2).hide()
		$('.clearHistoryLabel').hide()
		$(".main").children().children().find('div').eq(3).fadeIn()
	} else {
		$(".qingKong").css("opacity", "1")
		$('.searchResults').css('border', '')
		$(".main").children().children().find('div').eq(3).hide()
		$('.clearHistoryLabel').hide()
		$(".main").children().children().find('div').eq(2).fadeIn()
	}
}


// input清空按钮  清空输入框方法
function delThisinput(e) {
	$(e).prev().val("")
	$(".qingKong").css("opacity", "0")
	$('.clearHistoryLabel').hide()
	$('.searchResults').children().remove()
	$('.popularSearch').children().remove()
	$(".main").children().children().find('div').eq(2).hide()
	$(".main").children().children().find('div').eq(3).fadeIn()
}


//实时搜索监测input的value
$(".searchInput input").on("input", function () {
	var thisVal = $(this).val().toLowerCase()
	matchData(thisVal)
})


// 路线类型选择
$(".pathChoice div").on("click", function () {
	$(this).find("li").addClass("thisLiIsActive")
	$(this).siblings().find("li").removeClass()
	if ($(this).index() == 0) {
		$(".firstChoice").find("li").eq(1).children().remove()
		$(".firstChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".firstChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".secondChoice").find("li").eq(1).html(" ")
		$(".secondChoice").find("li").eq(1).append("<span></span>")
		$(".secondChoice").find("li").eq(2).find("span").html("查看扶梯路线")
		$(".lastChoice").find("li").eq(1).html(" ")
		$(".lastChoice").find("li").eq(1).append("<span></span>")
		$(".lastChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('liftsFirst')
	} else if ($(this).index() == 1) {
		$(".secondChoice").find("li").eq(1).children().remove()
		$(".secondChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".secondChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".firstChoice").find("li").eq(1).html(" ")
		$(".firstChoice").find("li").eq(1).append("<span></span>")
		$(".firstChoice").find("li").eq(2).find("span").html("查看直梯路线")
		$(".lastChoice").find("li").eq(1).html(" ")
		$(".lastChoice").find("li").eq(1).append("<span></span>")
		$(".lastChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('escalatorsFirst')
	} else if ($(this).index() == 2) {
		$(".lastChoice").find("li").eq(1).children().remove()
		$(".lastChoice").find("li").eq(1).html(formatSeconds(realTime))
		$(".lastChoice").find("li").eq(2).children().html('约' + realdistance + '米')
		$(".firstChoice").find("li").eq(1).html(" ")
		$(".firstChoice").find("li").eq(1).append("<span></span>")
		$(".firstChoice").find("li").eq(2).find("span").html("查看直梯路线")
		$(".secondChoice").find("li").eq(1).html(" ")
		$(".secondChoice").find("li").eq(1).append("<span></span>")
		$(".secondChoice").find("li").eq(2).find("span").html("查看楼梯路线")
		pathGo('stairsFirst')
	}
})


// input val值与后台数据匹配 并渲染
var searchResultsArr = []


// 排序方法截取第一位数
function compareOneDigit(property) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].charAt(0) != '' || b[property].charAt(0) != '') {
				var value1 = a[property].charAt(0)
				var value2 = b[property].charAt(0)
				// console.log(value1)
				return value1 - value2;
			}
		}
	}
}


// 楼层排序方法截取前面数字
function comparefloor(property, str, index) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].split(str)[index] != '' || b[property].split(str)[index] != '') {
				let value1 = parseInt(a[property].split(str)[index]) 
				let value2 = parseInt(b[property].split(str)[index]) 
				return value1 - value2;
			}
		}
	}
}


// 去掉转义字符以及特殊字符
function excludeSpecial(s) {
	// 去掉转义字符  
	s = s.replace(/[\'\\\/\b\f\n\r\t]/g, '');
	// 去掉特殊字符  
	// s = s.replace(/[\@\#\$\%\^\&\*\{\}\:\"\L\<\>\?] / );
	return s;
};


// 排序方法全词
function compare(property) {
	return function (a, b) {
		if (a[property]) {
			if (a[property].charAt(0) != '' || b[property].charAt(0) != '') {
				var value1 = a[property]
				var value2 = b[property]
				// console.log(value1)
				return value1 - value2;
			}
		}
	}
}


function compareInt(property) {
	return function (object1, object2) {
		var value1 = object1[property];
		var value2 = object2[property];
		return value1 - value2;
	}
}


// 实时搜索匹配方法  并传递搜索结果为数组
function matchData(val) {
	$('.searchResults').children().remove()
	$('.popularSearch').children().remove()
	searchResultsArr = []
	var li = ''
	var nameStr;
	if (allFloorData.length > 0) {
		for (var i = 0; i < allFloorData.length; i++) {
			searchList = allFloorData[i].Area;
			for (var j = 0; j < searchList.length; j++) {
				nameStr = searchList[j].AN
				if (nameStr.indexOf(val) != -1 && val != "") {
					searchResultsArr.push(searchList[j])
				}
			}
		}

		searchResultsArr = searchResultsArr.sort(compareOneDigit('Tag'))
		for (var o = 0; o < searchResultsArr.length; o++) {
			li = li + '<li onclick="toThisPoint(' + searchResultsArr[o].PI + ',' + "\'" + searchResultsArr[o].FloorID + "\'" + ',' + "\'" + searchResultsArr[o].AN + "\'" + ',' + 2 + ',' + "\'" + searchResultsArr[o].Tag + "\'" + ')">' + '<div class="searchResultsImg">' + '<span>' + '</span>' + '</div>' + '<div class="searchResultsInfo">' + '<span>' + searchResultsArr[o].AN + '</span>' + '<div>' + '</div>' + '<span class="searchResultsInfoFloor">' + searchResultsArr[o].Tag + '   ' + object.allFoors[searchResultsArr[o].FloorID] + '</span>' + '</div>' + '</li>'
		}
		$('.searchResults').append(li)
	} else if (allFloorData.length < 1) {
		$('.searchResults').css('border', '')
	}
}


// 退出导航几种方式
function exitNavigation(type) {
	if (type == 1) {
		$(".exitConfirmation").css("opacity", "1")
		$(".exitConfirmation").css("right", "0rem")
		$(".inNavigationBotBar").css("left", "7.3rem")
		setTimeout(() => {
			$(".inNavigationBotBar").css("opacity", "0")
		}, 500)
	} else if (type == 2) {
		$(".inNavigationBotBar").css("opacity", "1")
		$(".inNavigationBotBar").css("left", "0rem")
		$(".exitConfirmation").css("right", "7.3rem")
		setTimeout(() => {
			$(".exitConfirmation").css("opacity", "0")
		}, 500);
	} else if (type == 3) {
		setTimeout(() => {
			object.isTrue = true;
			audioAutoPlay("mo_yuyin", "导航结束", "5")
		}, 0);
		$('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
		$(".inNavigationTopBarBox,.inNavigationBotBarBox").fadeOut()
		exitNavigation(2)
		clearInterval(realTimeCountdown)
		clearInterval(object.timer)
		goBack()
	} else if (type == 4) {
		$('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
		$(".endOfNavigationBox,.inNavigationTopBarBox").fadeOut()
		$('.navigationCompletedPopUps').fadeIn()
		setTimeout(() => {
			$('.navigationCompletedPopUps').fadeOut()
		}, 1500);
		clearInterval(realTimeCountdown)
		clearInterval(object.timer)
		goBack()
	} else if (type == 5) {
		$('.floorToggle').html("" + object.allFoors[nowFloorId] + "")
		$(".endOfNavigationBox,.inNavigationTopBarBox").fadeOut()
		$('.navigationCompletedPopUps').fadeIn()
		setTimeout(() => {
			$('.navigationCompletedPopUps').fadeOut()
		}, 1500);
		commentPublic = $('.startEndPointRankLabelTextarea textarea').val()
		clearInterval(realTimeCountdown)
		clearInterval(object.timer)
		goBack()
		if (!rankPublic) {
			Review(MapConfig.projectID, 4, commentPublic)
		} else {
			Review(MapConfig.projectID, rankPublic, commentPublic)
		}

		rankPublic = ''
		commentPublic = ''
		$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
		$(".startEndPointRankLabel").css('height', '0')
		$(".startEndPointRankPickRemark").html("您对本次服务满意吗")
		$(".startEndPointRankLabelTextarea textarea").val('')
	}
}


// 进入评分页面
function enterRank() {
	$(".startEndPointInfo").fadeOut()
	$(".startEndPointRank").slideDown()
}


// 回车键调用搜索方法
$(document).keyup(function (event) {
	if ($('.enterMapO').css("display") == 'block') {
		if (event.keyCode == 13) {
			toSearchResultsOnMap()
		}
	}
});


//评分星星按钮
$(".starability_basic span").on("click", function () {
	$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
	var xxIndex = $(this).index()
	for (var i = 0; i < xxIndex + 1; i++) {
		$(".starability_basic").find("span").eq(i).css("background-image", "url('./images/icon_xingxing_xz.png')")
	}
	if (xxIndex == 0) {
		$(".startEndPointRankPickRemark").html("体验较差")
	} else if (xxIndex == 1) {
		$(".startEndPointRankPickRemark").html("体验一般")
	} else if (xxIndex == 2) {
		$(".startEndPointRankPickRemark").html("体验良好")
	} else if (xxIndex == 3) {
		$(".startEndPointRankPickRemark").html("比较满意")
	} else if (xxIndex == 4) {
		$(".startEndPointRankPickRemark").html("非常满意")
	}
	setTimeout(() => {
		$(".startEndPointRankLabel").css("height", "2.47rem")
	}, 0);
	rankPublic = $(this).index()

})


// 评分打标签
$(".startEndPointRankLabelWords span").on("click", function () {
	if ($(".startEndPointRankLabelTextarea textarea").val().indexOf($(this).html()) == -1) {
		$(".startEndPointRankLabelTextarea textarea").val($(".startEndPointRankLabelTextarea textarea").val() + " " + $(this).html())
	} else {
		return
	}
	commentPublic = $('.startEndPointRankLabelTextarea textarea').val()

})


//科室页  搜索结果   搜索多结果 点击方法
function toThisPoint(pointid, floorid, roomname, type, tag) {
	setTimeout(() => {
		yGetData.updateHotPoint(MapConfig.projectID, 'SC', 'AddSearchLog', "{'KEY':'" + pointid + "'}")
	}, 100);
	$(".searchResultsOnMapBox").hide()
	unableClick = {}
	if (type == 1) {
		self.map.regShowLoading(function (ccc) {
			// console.log(ccc);
			if (ccc == true) {
				$('.loadings').show()
			}
			if (ccc == false) {
				$('.loadings').hide()
			}
		})
		$(".searchResultsOnMapBox").show()
		if ($('.searchResultsOnMapBox').css("display") == 'block') {
			if (noMarkIsSetEnd == true) {
				self.map.addMarkToPoint(pointid, 'mark', true)
				unableClick.pointID = pointid
				unableClick.floorID = floorid
				unableClick.name = roomname
				if (tag) {
					unableClick.tag = tag
					object.floorName = tag + ' ' + object.allFoors[pointid]
				} else {
					object.floorName = object.allFoors[pointid]
				}
				object.mark = pointid
				object.floorid = floorid
				object.departName = roomname

				$('.shareDataInput').val(roomname)
				$('.shareDataInput').html(roomname)
				self.map.regShowLoading(function (ccc) {
					if (ccc == true) {
						$('.loadings').show()
					}
					if (ccc == false) {
						$('.loadings').hide()
					}
				})
				setTimeout(() => {
					$(".floorToggle").html(object.allFoors[floorid])
				}, 0);
			} else {
				self.map.selectByID(pointid, true)
			}
		} else {
			self.map.selectByID(pointid, true)
		}
	} else if (type == 2) {
		$(".homepage,.main").hide()
		$('.buildingBar').css('margin-top', '4rem')
		self.map.regShowLoading(function (ccc) {
			if (ccc == true) {
				$('.loadings').show()
			}
			if (ccc == false) {
				$('.loadings').hide()
			}
		})

		if (isStart == true && isEnd != true) {
			setPointType('start', pointid, floorid, roomname, tag)
		} else if (isEnd == true && isStart != true) {
			setPointType('end', pointid, floorid, roomname, tag)
		} else if (isEnd != true && isStart != true) {
			$('.setPoint').slideDown()
			isStartBtnOrEndBtn(3)
			setPointBottom()
			self.map.zoomLevel(8);
			self.map.addMarkToPoint(pointid, 'mark', true)
			unableClick.pointID = pointid
			unableClick.floorID = floorid
			unableClick.name = roomname
			if (tag) {
				unableClick.tag = tag
				$('.pointFloor').html(tag + ' ' + object.allFoors[floorid])
			} else {
				$('.pointFloor').html(object.allFoors[floorid])
			}

			object.mark = pointid
			object.floorid = floorid
			object.departName = roomname
			object.floorName = $('.pointFloor').html()
			$('.shareDataInput').val(roomname)
			$('.shareDataInput').html(roomname)
			$(".pointName").html(roomname)

			// console.log($('.searchResultsInfoFloor').html())
			setTimeout(() => {
				$(".floorToggle").html(object.allFoors[floorid])
			}, 0);
		}
		var sArr = {}
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		sArr.name = roomname
		if (tag) {
			sArr.floor = tag + ' ' + object.allFoors[floorid]
		} else {
			sArr.floor = object.allFoors[floorid]
		}

		if (keyArr == '' || keyArr == null) {
			var cArr = []
			cArr.push(sArr)
			localStorage.setItem(MapConfig.keyStorage, JSON.stringify(cArr))
		}
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		keyArr.push(sArr)
		localStorage.setItem(MapConfig.keyStorage, JSON.stringify(keyArr))
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		// console.log(keyArr)
	} else {
		if ($(".homePage").css('display') == 'block') {
			$(".homePage").hide()
			$('.buildingBar').css('margin-top', '4rem')
		} else if ($(".main").css('display') == 'block') {
			$(".main").hide()
		} else if ($(".searchResultsOnMapBox").css('display') == 'block') {
			$(".searchResultsOnMapBox").hide()
		}
		if ($('.setPointTip').css("display") == 'block' && $('.operation').css("display") == 'block') {
			if (object.endP == '' && object.startP != '') {
				setPointType('end', pointid, floorid, roomname)
			} else if (object.startP == '' && object.endP != '') {
				setPointType('start', pointid, floorid, roomname)
			} else {
				if (isStart == true) {
					setPointType('start', pointid, floorid, roomname)
				} else if (isEnd == true) {
					setPointType('end', pointid, floorid, roomname)
				}
			}
		} else if (isStart == true) {
			setPointType('start', pointid, floorid, roomname)
		} else if (isEnd == true) {
			setPointType('end', pointid, floorid, roomname)
		} else {
			self.map.selectByID(pointid, true)
		}
	}
}


// 按钮显示设为起点还是设为终点判断
function isStartBtnOrEndBtn(type) {
	$(".setPoint .right").children().remove()
	if (type == 1) { //setPointTips专场
		$('.searchResultsOnMapBox,.setPoint').hide()
		$('.setPointTip').slideDown()
	} else if (type == 2) { //searchResultsOnMapBtn专场
		$('.setPointTip,.setPoint').hide()
		$('.searchResultsOnMapBox').slideDown()
	} else if (type == 3) { //setPoint专场
		$('.searchResultsOnMapBox,.setPointTip').hide()
		$('.setPoint').slideDown()
	}
	if (isStart == true) {
		$(".setPointTips").html("起点")
		$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>设为起点</div>")
	} else if (isEnd == true) {
		$(".setPointTips").html("终点")
		$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		$(".setPoint .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
	} else {
		if ($('.opStartP').val() == '' && $('.opEndP').val() != '') {
			$(".setPointTips").html("起点")
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".setPoint .right").append("<div class = 'querenxuandian' onclick='setStartOrEnd()'>设为起点</div>")
		} else if ($('.opEndP').val() == '' && $('.opStartP').val() != '') {
			$(".setPointTips").html("终点")
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".setPoint .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
		} else if ($('.opEndP').val() == '' && $('.opStartP').val() == '') {
			$(".setPointTips").html("终点")
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".setPoint .right").append("<span class = 'setPointBtn' onclick='setStartOrEnd()'></span>")
		}
	}

}


//   接下来是设置起点还是终点
function setPointType(type, pointid, floorid, roomname, tag) {
	$('.setPointTip').hide()
	if (type == 'start') {
		object.startP = self.map.startPID = pointid
		if (tag) {
			$('.opStartP').val(tag + ' ' + object.allFoors[floorid] + ' ' + (roomname));

		} else {
			$('.opStartP').val(object.allFoors[floorid] + ' ' + (roomname));
		}

		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	} else if (type == 'end') {
		object.endP = self.map.endPID = pointid
		if (tag) {
			$('.opEndP').val(tag + ' ' + object.allFoors[floorid] + ' ' + (roomname));
		} else {
			$('.opEndP').val(object.allFoors[floorid] + ' ' + (roomname));
		}

		if (object.startP != '' && object.endP != '') {
			$(".selectionBox").slideDown()
			$('.selection').hide()
			$('.selectionLoading').show()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		}
	}
}


//  搜索结果置于地图表面 搜索结果li点击效果
$(".searchResultsOnMapContainer").on("click", 'li', function () {
	$(this).addClass("searchResultsLiIsClick")
	$(this).siblings().removeClass()
})


// 搜索结果置于地图表面 顶部点击收缩
$(".searchResultsOnMap div").eq(0).on("click", function () {

	if ($(".searchResultsOnMapTelescopic").css('display') == 'block') {
		console.log(2);
		$(".searchResultsOnMapTelescopic,.setPoint").slideUp()
		$(this).children().eq(0).html("查看其余" + $(".searchResultsOnMapContainer li").length + "个结果")
		$(this).removeClass().addClass("searchResultsOnMapTopBarIsClick")
		$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1rem')
		$(".floorToggle").css('bottom', '0.95rem')
	} else if ($(".searchResultsOnMapTelescopic").css('display') == 'none') {
		console.log(1);
		$(".searchResultsOnMapTelescopic").slideDown()
		$(this).removeClass().addClass("searchResultsOnMapTopBar")
		$(this).children().eq(0).html("收起搜索结果")
		dynamicBottom()
	}
})


//数组内对象去重    
function uniq(arr, name) {
	var hash = {};
	return arr.reduce(function (item, next) {
		hash[next[name]] ? '' : hash[next[name]] = true && item.push(next);
		return item;
	}, []);
}


//从搜索页 搜索按钮进入搜索结果置于地图表面
function toSearchResultsOnMap(name) {
	var li = ''
	noMarkIsSetEnd = false

	$(".searchResultsOnMapContainer,.searchResults").children().remove()
	if (searchResultsArr.length > 0) {
		var sArr = {}
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		if (name) {
			sArr.name = name
		} else if ($('.mainInput').val() != '') {
			sArr.name = $('.mainInput').val()
		}
		sArr.floor = '点击查看更多结果'
		if (keyArr == '' || keyArr == null) {
			var cArr = []
			cArr.push(sArr)
			localStorage.setItem(MapConfig.keyStorage, JSON.stringify(cArr))
		}
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		keyArr.push(sArr)
		localStorage.setItem(MapConfig.keyStorage, JSON.stringify(keyArr))
		keyArr = JSON.parse(localStorage.getItem(MapConfig.keyStorage))
		// console.log(keyArr)
		var keyArr = []
		noMarkIsSetEnd = true

		for (var i = 0; i < searchResultsArr.length; i++) {
			li = li + '<li onclick="toThisPoint(' + searchResultsArr[i].PI + ',' + "\'" + searchResultsArr[i].FloorID + "\'" + ',' + "\'" + searchResultsArr[i].BN + "\'" + ',' + 1 + ',' + "\'" + searchResultsArr[i].Tag + "\'" + ')">' + '<div>' + '<span>' + '</span>' + '</div>' + '<div>' + '<div>' + '<span>' + searchResultsArr[i].BN + '</span>' + '<span>' + searchResultsArr[i].Tag + " " + object.allFoors[searchResultsArr[i].FloorID] + '</span>' + '</div>' + '<div class="searchResultsEnterDetailsBtn">' + '<span>' + '</span>' + '</div>' + '</div>' + '</li>'
		}
		if (object.startP == '' && object.endP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if (object.endP == '' && object.startP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		} else if (object.startP == '' && object.endP == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
		if (isStart == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').fadeOut(500);
		} else if (isEnd == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').fadeOut(500);
		}
		$(".searchResultsOnMapContainer").append(li)
		$(".searchResultsOnMapContainer li").eq(0).click()
		$(".main").hide()
		if (searchResultsArr.length == 1) {
			$('.searchResultsEnterDetailsBtn').click()
			$('.searchResultsOnMapBox').slideUp()
			$('.setPoint').show()
			setPointBottom()
		} else {
			$(".searchResultsOnMapTelescopic").slideDown()
			$(".searchResultsOnMapBox").fadeIn()
			searchResultsOnMapBoxH = ($('.searchResultsOnMapBox').height()) / (document.documentElement.clientWidth / 7.5)
			setTimeout(() => {
				dynamicBottom()
			}, 500);
		}
		searchResultsArr = ''
	} else if (afterFastSearchData.length > 0) {
		noMarkIsSetEnd = true
		var lFloor = [],
			BFloor = [];
		afterFastSearchData.forEach(element => {
			element.floor = object.allFoors[element.FloorID]
		})
		afterFastSearchData.forEach(element => {
			if (element.floor.indexOf(undergroundCompareFloorName) != -1) {
				BFloor.push(element)
			} else if (element.floor.indexOf(compareFloorName) != -1) {
				lFloor.push(element)
			}
		})


		BFloor.sort(comparefloor('floor', undergroundCompareFloorName, undergroundCompareFloorNameIndex))
		lFloor.sort(comparefloor('floor', compareFloorName, compareFloorNameIndex))

		afterFastSearchData = BFloor.concat(lFloor);
		for (var i = 0; i < afterFastSearchData.length; i++) {
			li = li + '<li onclick="toThisPoint(' + afterFastSearchData[i].PI + ',' + "\'" + afterFastSearchData[i].FloorID + "\'" + ',' + "\'" + afterFastSearchData[i].BN + "\'" + ',' + 1 + ',' + "\'" + afterFastSearchData[i].T + "\'" + ')">' + '<div>' + '<span>' + '</span>' + '</div>' + '<div>' + '<div>' + '<span>' + afterFastSearchData[i].BN + '</span>' + '<span>' + afterFastSearchData[i].T + '   ' + object.allFoors[afterFastSearchData[i].FloorID] + '</span>' + '</div>' + '<div class="searchResultsEnterDetailsBtn">' + '<span>' + '</span>' + '</div>' + '</div>' + '</li>'
		}
		if (object.startP == '' && object.endP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
		} else if (object.endP == '' && object.startP != '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		} else if (object.startP == '' && object.endP == '') {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
		}
		if (isStart == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("设起点")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').fadeOut(500);
		} else if (isEnd == true) {
			$(".searchResultsOnMapBtn span").eq(1).html("去这里")
			$(".floorToggleMinUl").hide()
			$('.pathInfo').fadeOut(500);
		}
		$(".searchResultsOnMapContainer").append(li)
		$(".searchResultsOnMapContainer li").eq(0).click()
		if (afterFastSearchData.length == 1) {
			$('.searchResultsEnterDetailsBtn').click()
			$('.searchResultsOnMapBox').slideUp()
			$('.setPoint').show()
			setPointBottom()
		} else {
			$(".main").hide()
			$(".searchResultsOnMapTelescopic").slideDown()
			$(".searchResultsOnMapBox").fadeIn()
			searchResultsOnMapBoxH = ($('.searchResultsOnMapBox').height()) / (document.documentElement.clientWidth / 7.5)
			setTimeout(() => {
				dynamicBottom()
			}, 500);

		}
		afterFastSearchData = ''
	} else {
		$('.searchResults').append("<span>未查找到结果</span>")
	}
	if ($('.searchResultsOnMapContainer').children != '') {
		$('.searchResultsOnMapContainer').animate({
			scrollTop: 0
		}, 'normal');
	}
}


// 多结果搜索呈现于地图点击箭头跳转单项详情
$(".searchResultsOnMapContainer").on("click", '.searchResultsEnterDetailsBtn', function () {
	$(".pointName").html($(this).prev().children().eq(0).html())
	$('.pointFloor').html($(this).prev().children().eq(1).html())
	$(".searchResultsOnMapBox").slideUp()
	$(".setPoint").slideDown()
	isStartBtnOrEndBtn(3)
	setPointBottom()
})


// 根据情况选择设置起点方法还是设置终点方法
function setStartOrEnd() {
	if ($(".searchResultsOnMapBox").css('display') == 'block') {
		$(".searchResultsOnMapBox").hide()
	}
	setPointTipBottom()
	if (isStart || isEnd) {
		if (isStart == true) {
			if (unableClick.pointID) {
				unableClickFun(1)
			} else {
				setStart()
			}
		} else if (isEnd == true) {
			if (unableClick.pointID) {
				unableClickFun(2)
			} else {
				setEnd()
			}
		}
	} else {

		if (object.endP == '' && object.startP != '') {
			if (unableClick.pointID) {
				unableClickFun(2)
			} else {
				setEnd()
			}
		} else if (object.startP == '' && object.endP != '') {
			if (unableClick.pointID) {
				unableClickFun(1)
			}
		} else if (object.startP == '' && object.endP == '') {
			if (unableClick.pointID) {
				unableClickFun(2)
			} else {
				setEnd()
			}
		}
	}
}


// 没有点击事件的标签设起点终点方法
function unableClickFun(type) {
	if (type == 1) {
		$('.operation').show()
		object.startP = self.map.startPID = unableClick.pointID
		if (unableClick.tag) {
			$('#startPoint').val(unableClick.tag + ' ' + object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
		} else {
			$('#startPoint').val(object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
		}

		if (object.startP != '' && object.endP != '') {
			$('.selectionBox').show()
			$(".setPointTip").hide()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		} else {
			isStartBtnOrEndBtn(1)
			setPointTipBottom()
			$('.compass').css('top', '2.81rem')
		}
	} else if (type == 2) {
		$('.operation').show()
		object.endP = self.map.endPID = unableClick.pointID
		if (unableClick.tag) {
			$('#endPoint').val(unableClick.tag + ' ' + object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
		} else {
			$('#endPoint').val(object.allFoors[unableClick.floorID] + ' ' + (unableClick.name));
		}

		if (object.startP != '' && object.endP != '') {
			$('.selectionBox').show()
			$(".setPointTip").hide()
			selectionBoxBottm()
			setTimeout(() => {
				$(".loadings").hide()
				setTimeout(() => {
					$('.selection').fadeIn()
					$('.selectionLoading').hide()
				}, 500);
				pathGo('liftsFirst')
			}, 500);
		} else {
			isStartBtnOrEndBtn(1)
			setPointTipBottom()
			$('.compass').css('top', '2.81rem')
		}
	}
}


// 评分重置
function RankPageReset() {
	$(".starability_basic").find("span").css("background-image", "url('./images/icon_xingxing_mr.png')")
	$(".startEndPointRankLabel").css('height', '0')
	$(".startEndPointRankPickRemark").html("您对本次服务满意吗")
	$(".startEndPointRankLabelTextarea textarea").val('')
}


// 秒钟换算
function formatSeconds(value) {
	var theTime = parseInt(value); // 秒
	var theTime1 = 0; // 分
	var theTime2 = 0; // 小时
	if (theTime > 60) {
		theTime1 = parseInt(theTime / 60);
		theTime = parseInt(theTime % 60);
		if (theTime1 > 60) {
			theTime2 = parseInt(theTime1 / 60);
			theTime1 = parseInt(theTime1 % 60);
		}
	}
	if (parseInt(theTime) > 0) {
		var result = "" + parseInt(theTime) + "秒";
		if (theTime1 > 0) {
			result = "" + parseInt(theTime1) + "分" + result;
		}
		if (theTime2 > 0) {
			result = "" + parseInt(theTime2) + "小时" + result;
		}
	} else {
		var result = ''
		if (theTime1 > 0) {
			result = "" + parseInt(theTime1) + "分钟" + result;
		}
		if (theTime2 > 0) {
			result = "" + parseInt(theTime2) + "小时" + result;
		}
	}
	return result
}


// 强制关loading
$(".loadings div").on('click', function () {
	$(".loadings").fadeOut()
})


// 地图位置 大小初始化
function mapPositonReset() {
	if (object.isFind) {
		self.map.zoomLevel(pLevel)
	} else {
		mapResetPublic()
	}
}


// 滑动收起键盘
$(".searchResultsBox").on("touchstart", function (e) {
	$('.mainInput').blur()
});


// 选点模块出现后   楼层模块和缩放模块的bottom位置
function setPointBottom() {
	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '2.4rem');
	$(".floorToggle").css('bottom', '2.35rem')
}


function setPointTipBottom() {
	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '1.7rem');
	$(".floorToggle").css('bottom', '1.65rem')
}


function selectionBoxBottm() {
	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '3rem');
	$(".floorToggle").css('bottom', '2.95rem')
}


function normalBottom() {
	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '.3rem');
	$(".floorToggle").css('bottom', '.25rem')
}


function dynamicBottom() {
	if ($('.searchResultsOnMapContainer li').length == 1) {
		$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 1.9) + 'rem')
		$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 1.75) + 'rem')
	} else if ($('.searchResultsOnMapContainer li').length == 2) {
		$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 2.5) + 'rem')
		$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 2.35) + 'rem')
	} else if ($('.searchResultsOnMapContainer li').length > 2) {
		$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + 3) + 'rem')
		$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + 2.85) + 'rem')
	}
	$('.scale,.changeFBox,.floorToggleMinUl').css('bottom', '' + (searchResultsOnMapBoxH + .2) + 'rem')
	$(".floorToggle").css('bottom', '' + (searchResultsOnMapBoxH + .15) + 'rem')
}


function shareFun() {
	shareMiniProgram()
	shareMessage()
	shareTimeline()
}


function noShow() {
	$('.share_shade').hide()
}